home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / Asm / Screens / LoadPicture.s < prev    next >
Encoding:
Text File  |  1997-07-09  |  3.3 KB  |  127 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Name:      Load Picture
  3. ;Author:    Paul Manias
  4. ;Copyright: DreamWorld Productions (c) 1996-1997.  Freely distributable.
  5. ;
  6. ;This demo will load in a picture of any size/type and if it is larger than
  7. ;the screen width, it scrolls left and right.  This is easily possible due
  8. ;to the fact that GMS likes to fill in fields that have been set at zero
  9. ;on initialisation, which is great for loading/displaying things like
  10. ;pictures.
  11. ;
  12. ;The benefits of this will become more apparent when you want to do things
  13. ;like changing your graphics format from ECS to AGA and vice versa.  The
  14. ;benefits for the user are enormous (full graphical editing capabilities,
  15. ;if you program correctly).  And you don't even need to change a line of
  16. ;code!
  17.  
  18.     INCDIR    "INCLUDES:"
  19.     INCLUDE    "games/games_lib.i"
  20.     INCLUDE    "games/games.i"
  21.  
  22. SPEED    =    2
  23.  
  24.     SECTION    "Demo",CODE
  25.  
  26. ;===========================================================================;
  27. ;                             INITIALISE DEMO
  28. ;===========================================================================;
  29.  
  30.     STARTGMS
  31.  
  32. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  33.     move.l    GMSBase(pc),a6
  34.     moveq    #VIDEOMEM|GETPALETTE,d0
  35.     lea    PictureFile(pc),a1
  36.     CALL    LoadPicFile
  37.     move.l    d0,Picture
  38.     beq.s    .Error_Picture
  39.  
  40.     CALL    GetScreen
  41.     move.l    d0,Screen
  42.     beq.s    .Error_Screen
  43.  
  44.     move.l    Picture(pc),a0    ;a0 = Source structure.
  45.     move.l    Screen(pc),a1    ;a1 = Destination structure.
  46.     move.l    PIC_Data(a0),GS_MemPtr1(a1)
  47.     move.l    #HSCROLL,GS_Attrib(a1)
  48.     CALL    CopyStructure    ;>> = Copy Picture to Screen.
  49.  
  50.     move.l    Screen(pc),a0
  51.     CALL    AddScreen
  52.     tst.l    d0
  53.     beq.s    .Error_Screen
  54.  
  55.     CALL    ShowScreen
  56.  
  57.     bsr.s    Main    ;Go and do the main routine.
  58.  
  59. .ReturnToDOS
  60.     move.l    GMSBase(pc),a6
  61.     move.l    Screen(pc),a0
  62.     CALL    DeleteScreen
  63. .Error_Screen
  64.     move.l    Picture(pc),a1
  65.     CALL    FreePic
  66. .Error_Picture
  67.     MOVEM.L    (SP)+,A0-A6/D1-D7
  68.     moveq    #ERR_OK,d0
  69.     rts
  70.  
  71. ;===========================================================================;
  72. ;                                MAIN LOOP
  73. ;===========================================================================;
  74.  
  75. Main:    move.l    Screen(pc),a0
  76.     move.l    Picture(pc),a2
  77.     moveq    #0,d0    ;d0 = Initialise fader.
  78.     moveq    #2,d1    ;d1 = Speed of fade.
  79.     move.l    PIC_Palette(a2),a1
  80.     moveq    #$000000,d2
  81.     moveq    #0,d3
  82.     move.l    PIC_AmtColours(a2),d4
  83. .Fade1    CALL    WaitVBL
  84.     CALL    ColourToPalette    ;Do the fade routine.
  85.     tst.w    d0    ;Has the fade finished yet?
  86.     bne.s    .Fade1    ;If not, keep doing it.
  87.  
  88.     move.l    Picture(pc),a1
  89.     moveq    #0,d2
  90. .loop    CALL    WaitVBL
  91.     move.w    GS_ScrWidth(a0),d0    ;Only scroll the picture if is is
  92.     lsr.w    #3,d0    ;bigger than the actual screen.
  93.     cmp.w    GS_PicWidth(a0),d0
  94.     bge.s    .done
  95.  
  96.     tst.w    d2
  97.     bgt.s    .Right
  98. .Left    tst.w    GS_PicXOffset(a0)
  99.     ble.s    .RRight
  100. .RLeft    moveq    #-SPEED,d2
  101.     bra.s    .scroll
  102. .Right    move.w    GS_PicWidth(a0),d0    ;d0 = PicWidth.
  103.     sub.w    #320,d0
  104.     cmp.w    GS_PicXOffset(a0),d0    ;d0 = Is (Width-320 < PicOffset)?
  105.     ble.s    .RLeft
  106. .RRight    moveq    #SPEED,d2
  107. .scroll    add.w    d2,GS_PicXOffset(a0)
  108.     CALL    MovePicture
  109.  
  110. .done    moveq    #JPORT1,d0    ;Port 1 (Mouse)
  111.     moveq    #JT_ZBXY,d1
  112.     CALL    ReadJoyPort
  113.     btst    #MB_LMB,d0
  114.     beq.s    .loop
  115.     rts
  116.  
  117. ;===========================================================================;
  118. ;                                  DATA
  119. ;===========================================================================;
  120.  
  121. Screen:    dc.l    0
  122. Picture    dc.l    0
  123.  
  124. PictureFile:
  125.     dc.b    "GMS:demos/data/PIC.Pic640x256",0
  126.     even
  127.